package com.hopedove.workshop.databinding

import android.content.Context
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import android.widget.TextView
import androidx.databinding.BindingAdapter


@BindingAdapter("setOnActionDone")
fun EditText.setOnActionDone(func: (() -> Unit)?) {
    func?.let {
        imeOptions = EditorInfo.IME_ACTION_DONE
        this.setOnEditorActionListener { v, actionId, _ ->
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                it.invoke()
                val manager =
                    v.context.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
                manager?.hideSoftInputFromWindow(v.windowToken, 0)
            }
            true
        }
    }
}


fun TextView.setCheckToggle() {

}
